package com.isunland.managesystem.adapter;

import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseButterKnifeAdapter;
import com.isunland.managesystem.base.BaseVolleyActivity;
import com.isunland.managesystem.entity.LatestAnnounceMent.AnnounceMentDetail;
import java.util.ArrayList;

/**
 * 对象功能:
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: wangyanan
 * 创建时间: 2017/4/5 15:01
 */

public class LatestAnnounceMentAdapter extends BaseButterKnifeAdapter<AnnounceMentDetail> {

  @SuppressWarnings("unused") public LatestAnnounceMentAdapter(BaseVolleyActivity context,
      ArrayList<AnnounceMentDetail> objects) {
    super(context, objects);
  }

  @Override protected int setLayoutId() {
    return R.layout.adapter_latest_announcement;
  }

  @NonNull @Override protected BaseViewHolder initHolder(View convertView) {
    return new ViewHolder(convertView);
  }

  @Override
  protected void initView(AnnounceMentDetail item, BaseViewHolder baseHolder, int position) {
    ViewHolder vh = (ViewHolder) baseHolder;
    vh.tvType.setText(item.getDocKindName());
    //noinspection deprecation
    vh.isRead.setVisibility(
        (item.getIsRead() != null && "F".equalsIgnoreCase(item.getIsRead())) ? View.VISIBLE
            : View.GONE);
    vh.tvBrief.setText(item.getTitle());
    vh.tvNumber.setText(item.getDocKnowledgeNo());
    vh.tvName.setText(item.getRegStaffName());
    vh.tvDate.setText(item.getPublishDate());
  }

  @Override public boolean isEmpty() {
    return false;
  }

  protected class ViewHolder extends BaseViewHolder {
    //view
    @BindView(R.id.tv_type) TextView tvType;
    @BindView(R.id.is_read) TextView isRead;
    @BindView(R.id.tv_brief) TextView tvBrief;
    @BindView(R.id.tv_number) TextView tvNumber;
    @BindView(R.id.tv_name) TextView tvName;
    @BindView(R.id.tv_date) TextView tvDate;

    ViewHolder(View view) {
      super(view);
    }
  }
}
